package com.jiandan.load;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jiandan.bean.JanDanNew;

public class JanDanNewAdpter extends BaseAdapter {
    private Context context;
    private List<JanDanNew> list;

    public JanDanNewAdpter(Context convert, List<JanDanNew> url) {
        this.context = convert;
        this.list = url;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        view = convertView;
        ViewHolder holder = null;
        if (convertView == null) {
            view = LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_1, null);
            holder = new ViewHolder();
            holder.text = (TextView) view.findViewById(android.R.id.text1);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        JanDanNew dan = list.get(position);
        holder.text.setTextSize(15);
        holder.text.setText(dan.getDate()+"\t\t\t"+dan.getTitle()+"\t\t["+dan.getReplyCount()+"]");
        return view;
    }

    static class ViewHolder {
        TextView text;
    }
}
